import java.io.PrintWriter;
import java.util.HashMap;

class ComplexDeclaration extends Declaration {
	private String id1;
	private String id2;

	public ComplexDeclaration(String str1, String str2) {
		id1 = str1;
		id2 = str2;
	}

	public void print(PrintWriter pw) {
		pw.println("ID 1: " + id1);
		pw.println("ID 2: " + id2);
	}

	public String translate(HashMap<String, PrintWriter> pws, String condition, SymbolTable rt,
			String parent) {
		String key = rt.getStack().get(1);
		PrintWriter pw = pws.get(key);
		
		pw.println(id1+" "+id2 + " = new "+id1+"();");
        pw.println();
        pw.println("public static ImagePanel "+ id2+"Panel;");

        pw.println("private int hungry"+";");
        pw.println("private JLabel hungryLabel"+";");
        pw.println("private JTextField hungryText"+";");

        pw.println("private int tidy"+";");
        pw.println("private JLabel tidyLabel"+";");
        pw.println("private JTextField tidyText"+";");
        
        pw.println();
        pw.println("public void initialize() {");
        pw.println("this.setSize(800,600);");
        pw.println("this.setLayout(null);");
        pw.println("this.setDefaultCloseOperation("+id1+".EXIT_ON_CLOSE);");
        pw.println("this.setResizable(false);");
        pw.println("this.setLocation(50,50);");
        pw.println();
        pw.println("int xCoordinate=0;");
        pw.println("int yCoordinate=0;");
        pw.println("int ylCoordinate=0;");
        pw.println();
        pw.println(id2+"Panel = new ImagePanel();");
        pw.println(id2+"panel.setSize(600,460);");
        pw.println("this.add("+id2+"Panel);");
        pw.println("xCoordinate = "+id2+"Panel.getWidth();");
        pw.println("yCoordinate = "+id2+"Panel.getHeight();");
        pw.println();
        pw.println("this."+"hungry "+"= new JLabel("+"hungry"+");");
        pw.println("this."+"hungry"+".setLocation(xCoordinate,0);");
        pw.println("this."+"hungry"+".setSize(200,50);");
        pw.println("this.add("+"hungry"+");");  
        pw.println("yCoordinate="+"hungry"+".getY();");
        pw.println(); 
        pw.println("this."+"hungry"+"Text"+"= new JTextField("+"100"+");");
        pw.println("this."+"hungry"+"Text"+".setEditable(false);");
        pw.println("this."+"hungry"+"Text"+".setLocation(xCoordinate,yCoordinate+40);");
        pw.println("this."+"hungry"+"Text"+".setSize(200,30);");
        pw.println("this.add("+"hungry"+"Text"+");");  
        pw.println("yCoordinate="+"hungry"+"Text"+".getY();");
        pw.println(); 
        pw.println("this."+"tidy "+"= new JLabel("+"tidy"+");");
        pw.println("this."+"tidy"+".setLocation(xCoordinate,yCoordinate+40);");
        pw.println("this."+"tidy"+".setSize(200,50);");
        pw.println("this.add("+"tidy"+");");  
        pw.println("yCoordinate="+"tidy"+".getY();");
        pw.println();  
        pw.println("this."+"tidy"+"Text"+"= new JTextField("+"100"+");");
        pw.println("this."+"tidy"+"Text"+".setEditable(false);");
        pw.println("this."+"tidy"+"Text"+".setLocation(xCoordinate,yCoordinate+40);");
        pw.println("this."+"tidy"+"Text"+".setSize(200,30);");
        pw.println("this.add("+"tidy"+"Text"+");");  
        pw.println("yCoordinate="+"tidy"+"Text"+".getY();");
        pw.println();  
        pw.println("this.setVisible();");                   
        pw.println("}");
        pw.println();
		return null;
	}
}
